package cc.javaee.bbs.dao.activity;

import cc.javaee.bbs.dao.BaseDao;
import cc.javaee.bbs.model.activity.KbrCircle;
import cc.javaee.bbs.params.DbResultMap;
import cc.javaee.bbs.params.WebParams;
import cc.javaee.bbs.tool.DataFormatUtil;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class CircleDao extends BaseDao {
	String ns="kbr_circle.";
	
	public List<KbrCircle> find(KbrCircle KbrCircle) {
		List<KbrCircle> list=this.getSqlSession().selectList(ns+"find", KbrCircle);
		if(list!=null&&list.size()>0){
			for (KbrCircle act : list) {
			}
		}
		return list;
	}
	public List<DbResultMap> findDbList(WebParams param) {
		param.put("actStatus", "正在进行");//活动的状态是正在进行的
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", param);
		if(list!=null&&list.size()>0){
			for (DbResultMap act : list) {
				act.put("enStartTimeStr", DataFormatUtil.toDateStrNull(act.getDate("enStartTime")));
				act.put("enEndTimeStr", DataFormatUtil.toDateStrNull(act.getDate("enEndTime")));
				act.put("startTimeStr", DataFormatUtil.toDateStrNull(act.getDate("startTime")));
				act.put("endTimeStr", DataFormatUtil.toDateStrNull(act.getDate("endTime")));
			}
		}
		return list;
	}
	
	public void insert(KbrCircle KbrCircle) {
		this.getSqlSession().insert(ns+"insert", KbrCircle);
	}

	public void delete(Integer id) {
		this.getSqlSession().delete(ns+"delete", id);
	}

	public void update(KbrCircle KbrCircle) {
		this.getSqlSession().update(ns+"update", KbrCircle);
	}
	public void updatejifen(Integer userid) {
		this.getSqlSession().update(ns+"updatejifen", userid);
	}
	public Map<String, Object> userjifengroup(KbrCircle user) {
		return this.getSqlSession().selectOne(ns+"getjifengroup", user);
	}
	public Map<String, Object> findziliao(KbrCircle user) {
		return this.getSqlSession().selectOne(ns+"findziliao", user);
	}
	public void updateuseronlinetime(KbrCircle user) {
		this.getSqlSession().update(ns+"updateuseronlinetime", user.getId());
	}



}